
import { EventBus } from '@/store/index'
import { mapActions, mapGetters } from 'vuex'
import { isWeibo, isJSON } from '@/plugins/utils'
import { COMPONENT_TYPES, EVENTS_RESULTS_TYPES_MAP } from '@/common/const'
import { GENERAL_TYPES_MAP, FRIEND_RANK_TYPES_MAP } from '@/common/const-general'
import { EVENT_HOVER_TYPES, isWbEvent, FRONT_EVENTS, STATISTIC_DATA_TYPES_MAP } from '@/common/events'
import ShakeEvent from '@/components/events/ShakeEvent'
import axios_ from '@/utils/axios'
import { isHasOwnProperty, getCompIdByParam } from '@/plugins/utils'

export const pageTemplate = {
  computed: {
    pageOrCompEvents(){
      return this.item && this.item.events || this.currentPage && this.currentPage.events;
    },
    ...mapGetters({
      globalCurrentPage: "getCurrentPage",
    }),
  },
  methods: {
    ...mapActions({
      updateActivityInfo: "updateActivityInfo",
    }),
    pageInitEvents(){
      this.popArr(this.initEvents);
      this.popArr(this.loadEvents);
      this.popArr(this.commonFrontEvents);
      this.popArr(this.commonEvents);

      this.initEventsFun()
      this.onInitEvent()
      if(_.size(this.loadEvents) > 0){
        EventBus.$off("reloadLoad", this.onReloadLoad)
        EventBus.$on("reloadLoad", this.onReloadLoad)
      }
      EventBus.$off("reloadInit", this.onReloadInit)
      EventBus.$on("reloadInit", this.onReloadInit)
    },
    popArr(arr){
      while(arr && arr.length > 0){
        arr.pop();
      }
    },
    getAttrNameByParam(str){
      let attrName = null;
      if(str && str.length > 0){
        let arr = str.split("$");
        if(arr.length > 1){
          attrName = arr[1];
        }
      }
      return attrName;
    },
    onReloadInit({ popId, pageId }) {
      //页面
      if(this.statePopId <= 0 && (this.pageId == pageId || (this.pageId > 0 && this.pageId == pageId))){
        this.onInitEvent()
      }
      //弹层
      if(this.statePopId > 0 && (this.popId == popId || (this.popId > 0 && this.popId == popId))){
        this.onInitEvent()
      }
    },
    onReloadLoad({ popId, pageId }){
      //页面
      if(this.statePopId <= 0 && (this.pageId == pageId || (this.pageId > 0 && this.pageId == pageId))){
        this.onLoadEvent()
      }
      //弹层
      if(this.statePopId > 0 && (this.popId == popId || (this.popId > 0 && this.popId == popId))){
        this.onLoadEvent()
      }
    },
    async initPost(url, params) {
      if (this.isH5Edit) {
        return;
      }
      let item = params.item || this.item || this.currentPage
      if (item && item.id && !params.com_id) {
        params.com_id = item.id
      }
      params.site_id = this.siteInfo.id
      let event = params.event
      let type = event && event.type ? event.type : item.cid
      let eventAttr = item && item.eventAttr
      let controlId = event && event.controlId
      // let isUid = params.isUid
      delete params.event
      delete params.item
      delete params.controlId
      delete params.isUid
      delete params.rankType

      let { data } = await axios_.post(url, params)

      let isResultDisplay = params.isResultDisplay;

      if(event && event.isInitComp && this.siteInfo.pageOrPopComNum > 0){
        let pageOrPopComNum = this.siteInfo.pageOrPopComNum - 1
        this.$store.commit("updatePageOrPopComNum", { pageOrPopComNum })
      }

      let isSuccess = false;
      if (data.code == 0) {
        isSuccess = true;
        this.setInitStoreData({type, params, controlId, data})
      } else {
        if (data.code == "900010" && (!params.ele_key || (params.ele_key && params.ele_key != GENERAL_TYPES_MAP.activity))){
          // if (this.$refs.login) {
          //   this.$refs.login.show();
          // } else {
          //   this.$nextTick(function () {
          //     EventBus.$emit('login')
          //   })
          // }
        } else {
          if(parseInt(data.code) > 920000 && parseInt(data.code) < 929999){
            if (type == EVENT_HOVER_TYPES.judgeRightWrong.type) {
              let data_ = { id: params.com_id, controlId, eles:data.data.ele, right:data.data.right }
              this.$store.commit('updateJudgeRightWrong', data_)
            }
          }else if(parseInt(data.code) == 900007){
            this.showAlert(data.msg);
          }
        }
      }
      if(isResultDisplay && eventAttr){
        if(data.code != 0) {
          isSuccess = false
        }
        //是否参数修改数据为结果数据，后使用接口的结果类型来显示通讯后的结果提示
        if(isSuccess && event.type == EVENT_HOVER_TYPES.statisticData.type){
          if(_.isBoolean(data.data) && !data.data){
            isSuccess = data.data
          }
        }
        this.setinitResultDisplay( { isSuccess, eventAttr, type})
      }
    },
    showAlert(error) {
      this.$dialog.alert({
        title: '',
        message: error,
      })
    },
    setinitResultDisplay({ isSuccess, eventAttr, type }){
      if(eventAttr.resultType == EVENTS_RESULTS_TYPES_MAP.page) {
        // 触发事件后 跳转页面
        let pageId;
        if(isSuccess) {
          pageId = eventAttr.successPanelId;
        }else {
          pageId = eventAttr.failPanelId;
        }
        if(pageId){
          this.showPage(pageId);
        }
      } else if (eventAttr.resultType == EVENTS_RESULTS_TYPES_MAP.pop) {
        let popId
        if (isSuccess) {
          popId = eventAttr.successPanelId
        } else {
          popId = eventAttr.failPanelId
        }
        if (popId) {
          this.showPop(popId);
        }
      } else if (eventAttr.resultType == EVENTS_RESULTS_TYPES_MAP.jump) {
        //触发事件后跳转
        if (isSuccess && eventAttr.link.length > 0) {
          this.openLinkBySelfUrl(eventAttr.link);
        }
      }else if (eventAttr.resultType == EVENTS_RESULTS_TYPES_MAP.component) {
        //一个组件只能走一次这个代码
        if (type == eventAttr.eventType) {
          //动态组件 在ui中直接显示结果
          this.$store.commit('resetVisibleComponents_')

          let commonAttr = { isVisible: true }
          let compId
          if (isSuccess) {
            compId = eventAttr.successCompId
          } else {
            compId = eventAttr.failCompId
          }
          let relateCompId = getCompIdByParam(compId)
          if (relateCompId) {
            this.$store.commit('updateComponentVisible', { id: relateCompId, commonAttr })
          }
        }
      }
    },
    async setInitStoreData({type, params, controlId, data}){
      if (type == EVENT_HOVER_TYPES.number.type) {
        let data_ = { id: params.com_id, controlId, data: data.data }
        this.$store.commit('setWbInitNumber', data_)
      }else if (type == EVENT_HOVER_TYPES.numberDayExists.type) {
        let data_ = { id: params.com_id, controlId, data: data.data }
        this.$store.commit('setNumberDayExists', data_)
      }else if (type == EVENT_HOVER_TYPES.generalNum.type) {
        let data_ = { id: params.com_id, controlId, data: data.data }
        this.$store.commit('setWbInitNumber', data_)
      }else if (type == EVENT_HOVER_TYPES.vote.type) {
        let data_ = { id: params.com_id, controlId, data: data.data }
        this.$store.commit('setWbInitVote', data_)
      }else if( type == EVENT_HOVER_TYPES.isFollow.type){
        //接口返回是否关注过需要关注的用户，如果关注过就不显示全局关注组件
        // data: false
        let data_ = { isFollowedObj: {} }
        data_.isFollowedObj[params.uidb] = data.data;
        this.$store.commit('updateGlobalPost', data_);
        let compData = this.componentMap[params.com_id];
        if(compData.cid == COMPONENT_TYPES.wb_btn) {
          let isNumber = !data.data;
          EventBus.$emit("refreshNumberDayExists", { compId: compData.id, isNumber });
        }else if(compData.cid == COMPONENT_TYPES.wb_is_post_event) {
          this.$store.commit('updateComponentAttr', { id: params.com_id, commonAttr: { isVisible: !data.data } })
        }
      }else if (type == EVENT_HOVER_TYPES.user.type || type == COMPONENT_TYPES.wb_input) {
        let data_ = { id: params.com_id, controlId, data: data.data }
        if(!params.uids || params.uids.length <= 0){
          this.$store.commit('setWbUserInfo', data_)
        }
        //自动填写用户姓名时controlId为空，只有全局wbUserData
        if(controlId){
          this.$store.commit('setUserList', data_)
        }
      } else if (type == EVENT_HOVER_TYPES.statisticData.type) {
        let data_ = { id: params.com_id, controlId, data: data.data }
        if(data_.data.interact_uid && data_.data.interact_uid.length > 0 && data_.data.interact_uid != '0'){
          _.merge(params,{uids: data_.data.interact_uid})
          let user  = await axios_.post('/feinit/wb_head', params)
          if(user.data.data.users){
            data_.data.elements = user.data.data.users
          }else{
            data_.data.elements = [user.data.data]
          }
        }
        this.$store.commit('setStatisticData', data_)
      } else if (type == EVENT_HOVER_TYPES.reposts.type) {
        let data_ = { id: params.com_id, controlId, data: data.data }
        this.$store.commit('setReposts', data_)
      } else if (type == EVENT_HOVER_TYPES.saveImg.type) {
        this.$store.commit('updateFileUploadData', data)
      } else if (type == EVENT_HOVER_TYPES.rankFriend.type) {
        let data_ = { id: params.com_id, rankType: params.rankType, controlId, data:data.data }
        this.$store.commit('setFriends', data_)
      } else if (type == EVENT_HOVER_TYPES.judgeRightWrong.type) {
        //获取通用
        let data_
        if(params.type == GENERAL_TYPES_MAP.activity){
          data_ = { id: params.com_id, controlId, data:data.data }
          this.$store.commit('updateInitGeneral', data_)
        }else if(params.type == GENERAL_TYPES_MAP.gaobai){
          data_ = { id: params.com_id, controlId, eles:data.data.ele, right:data.data.right, row: data.data.row}
          this.$store.commit('updateJudgeRightWrong', data_)
        }else if(params.type == GENERAL_TYPES_MAP.area){
          this.$store.dispatch('updateArea', { id: params.com_id, controlId, type: params.type, data: data.data })
        }else if(params.type == GENERAL_TYPES_MAP.areaRank){
          this.$store.commit('updateAreaRank', { id: params.com_id, controlId, type: params.type, data: data.data })
        }else if(params.type == GENERAL_TYPES_MAP.puzzle){
          this.$store.commit('updatePuzzle', { id: params.com_id, controlId, type: params.type, data: data.data })
        }else if(params.type == GENERAL_TYPES_MAP.draw){
          this.$store.commit('updateDraw', { id: params.com_id, controlId, type: params.type, data: data.data })
        }else if(params.type == GENERAL_TYPES_MAP.lotteryForm) {
          //刷新动态图片和文字
          let lottery = data.data.luck_list && data.data.luck_list[0];
          if(lottery && (lottery.ele_name || lottery.ele_url)){
            this.$store.commit('updateBindData', {key: 'lotteryUrl', value: lottery.ele_url});
            this.$store.commit('updateBindData', {key: 'lotteryName', value: lottery.ele_name});
            EventBus.$emit("refreshDynamicData")
          } else {
            data.code = -1
          }
        } else if(params.type == GENERAL_TYPES_MAP.formrandlist) {
          this.$store.commit('updateFormrandlist', { id: this.item.id, controlId, type: params.type, formList: data.data })
        }
      } else if (type == EVENT_HOVER_TYPES.activityInfo.type) {
        //tree 七夕活动tree
        if(params.type == GENERAL_TYPES_MAP.tree){
          let data_ = { id: params.com_id, controlId, data:data.data }
          this.updateActivityInfo(data_)
        }else if(params.type == GENERAL_TYPES_MAP.lotteryForm){
          //抽奖后没有填写表单信息，再次点击抽奖按钮判断，弹出填写表单信息页面
        }
      }else if(type == 'initTime'){
        let data_ = { id: params.com_id, controlId, data:data.data }
        this.$store.commit('updateTime', data_)
      }
    },
    initEventsFun(){
      let events = this.pageOrCompEvents
      if(!events || _.size(events) <= 0){
        return
      }
      let tempArr = [];
      let tempActionWbArr = [];
      _.forEach(events, (event) => {
        if(!isHasOwnProperty(event, "mouseBehavior") || event.mouseBehavior != "data"){
          tempArr.push(event)
          if(event.controlId && event.controlId.length > 0 && isHasOwnProperty(event, "mouseBehavior")){
            tempActionWbArr.push(event)
          }
        }
      })
      tempArr = _.sortBy(tempArr, (event) => { return event.index; });
      let sortedActionWbEvents = _.sortBy(tempActionWbArr, function(event) { return event.index; });

      if(sortedActionWbEvents.length > 0){
        this.mainControlId = sortedActionWbEvents[0].controlId
      }

      _.forEach(tempArr, (event) => {
        if(event.isInitComp){
          this.initEvents.push(event)
        }
        if(event.mouseBehavior == "click"){
          if(event.controlId && event.controlId.length > 0){
            this.wbEvents.push(event)
            this.wbTypes.push(event.type)
          }else{
            if(FRONT_EVENTS.indexOf(event.type) != -1 || event.comps[0].attrs.isCommonFrontEvents){
              this.commonFrontEvents.push(event)
            }else{
              this.commonEvents.push(event)
            }
          }
        }
        if(event.mouseBehavior == "load"){
          if(event.type == EVENT_HOVER_TYPES.shake.type){
            ShakeEvent.shakeEvent.initShakeData({item:this.item, event, isPostWbEventOrCommonEvents: this.isPostWbEventOrCommonEvents});
            ShakeEvent.shakeEvent.initShake();
          }else {
            if(FRONT_EVENTS.indexOf(event.type) != -1 || event.comps[0].attrs.isCommonFrontEvents){
              this.commonFrontEvents.push(event)
            }
            this.loadEvents.push(event)

            if(event.controlId && event.controlId.length > 0){
              this.wbTypes.push(event.type)
            }
          }
        }
      })
    },
    onLoadEvent(){
      //加载截图，发博操作，需要发博事件的操作类型配置为click，这样就在加载时不会执行，在截图后会去执行click发博事件
      if(this.pageOrCompEvents.saveImg){
        this.onLoadEventCb();
      }else{
        this.executeLoadEvent();
      }
    },
    onLoadEventCb(){
      // let jumpUrl = "saveImg"
      // let comType = "onload"
      // let wModule = "saveImg"
      // this.onPostStatics(null, { comType, wModule,  jumpUrl })

      //截图容器，监测图片是否加载完，加载后在调用
      const event = this.pageOrCompEvents.saveImg;
      const cropConId = event.comps[1].attrs.value;
      const cropCompId = this.getAttrNameByParam(cropConId);
      this.loadImgNum = 0;
      this.loadedImgNum = 0;
      if(cropCompId){
        let compData = this.componentMap[cropCompId];
        this.loadedImgs(compData, true);
        this.loadEventCb = window.setInterval(() => {
          this.loadedImgNum = 0;
          this.loadedImgs(compData, false);
          if(this.loadedImgNum >= this.loadImgNum){
            window.clearInterval(this.loadEventCb);
            this.executeLoadEvent();
          }
        }, this.siteInfo.reloadTime)
      }else{
        _.forEach(this.globalCurrentPage.components, (compData) => {
          this.loadedImgs(compData, true);
        })
        this.loadEventPageCb = window.setInterval(() => {
          this.loadedImgNum = 0;
          _.forEach(this.globalCurrentPage.components, (compData) => {
            this.loadedImgs(compData, false);
          })
          if(this.loadedImgNum >= this.loadImgNum){
            window.clearInterval(this.loadEventPageCb);
            window.setTimeout(() => {
              this.executeLoadEvent();
            }, this.siteInfo.reloadTime);
          }
        }, this.siteInfo.reloadTime)
      }
    },
    executeLoadEvent(){
      let e = {}
      _.forEach(this.loadEvents, (loadEvent) => {
        let isWbEvent_ = isWbEvent(loadEvent)
        if(isWbEvent_){
          this.postWbEvent( { loadEvent, e } )
        }else{
          if(this.commonFrontEvents.length > 0){
            this.onFrontEvents( e, this.commonFrontEvents)
          }else{
            this.frontEvent( { event:loadEvent, e } )
          }
        }
      })
    },
    onInitEvent(){
      _.forEach(this.initEvents, (event) => {
        let itemControls = this.getItemControls
        let controlData = itemControls && itemControls[event.controlId]
        if(event.type == EVENT_HOVER_TYPES.vote.type){
          let vote_ids = []
          let voteObj = itemControls[event.controlId].data.elements
          _.forEach(voteObj, (item, key) => {
            vote_ids.push(key)
          })
          //只有日历会开启isUid这个开关 每日投票是根据计数来控制的
          if(controlData.data.isUid){
            this.initPost("/feinit/vote_list", {event, vote_ids: vote_ids.join()})
          }else{
            this.initPost("/feinit/vote", {event, vote_ids: vote_ids.join()})
          }
        }else if(event.type == EVENT_HOVER_TYPES.number.type){
          this.initPost("/feinit/number", {event})
        }else if(event.type == EVENT_HOVER_TYPES.numberDayExists.type){
          if(controlData.data.isGlobal) {
            this.initPost("/feinit/number_exists", {event})
          } else {
            this.initPost("/feinit/number_dayexists", {event})
          }
        }else if(event.type == EVENT_HOVER_TYPES.generalNum.type){
          //进度条 统计参与活动用户数
          this.initPost("/feinit/general_num", {event, ele_key: controlData.data.ele_key})
        }else if(event.type == EVENT_HOVER_TYPES.isFollow.type){
          if(event.comps[1].attrs.value) {
            this.initPost("/feinit/wb_friendship", { event, uidb: event.comps[1].attrs.value })
          }
        }else if(event.type == EVENT_HOVER_TYPES.reposts.type){
          if(event.isPost || !itemControls){
            return
          }
          let mids = []
          let lists = itemControls[event.controlId].data.elements
          _.forEach(lists, (item) => {
            if(item.mid.length > 0){
              item.mid = item.mid.replace(/\s*/g,"")
              mids.push(item.mid)
            }
          });
          mids = _.uniq(mids);
          if(mids.length > 0){
            event.isPost = true
            let params = {event, mids: mids.join()}
            if(this.pageOrCompEvents.vote){
              this.initPost("/feinit/wbcardlist", params)
            }else{
              window.setTimeout( () => {
                this.initPost("/feinit/wbcardlist", params)
              }, this.siteInfo.repostsDelayTime)
              this.$store.commit('updateRepostsDelayTimeTime')
            }
          }else{
            let pageOrPopComNum = this.siteInfo.pageOrPopComNum - 1
            this.$store.commit("updatePageOrPopComNum", { pageOrPopComNum })
          }
        }else if(event.type == EVENT_HOVER_TYPES.rankFriend.type){
          if(event.isPost || !itemControls){
            return
          }
          let rankType = itemControls[event.controlId].data.rankType
          let params = {event, uid: this.userInfo.uid, rankType}
          if(rankType == FRIEND_RANK_TYPES_MAP.friends){
            //获取好友列表
            event.isPost = true
            this.initPost("/feinit/wb_friends", params)
          }else if(rankType == FRIEND_RANK_TYPES_MAP.rank){
            if(event.isPost){
              return
            }
            //获取七夕好友能量排行榜 及 计数排行榜
            let relateCompId = getCompIdByParam(controlData.data.relateCompId)
            if(relateCompId){
              params.relate_comp_id = relateCompId
            }
            event.isPost = true
            this.initPost("/feinit/number_rank", params)
          }
        }else if(event.type == EVENT_HOVER_TYPES.judgeRightWrong.type){
          let ele_key = itemControls[event.controlId].data.ele_key
          let relateCompId = getCompIdByParam(itemControls[event.controlId].data.relateCompId);
          let params = { event, ele_key, type: ele_key, controlId: event.controlId }
          if(relateCompId){
            params.com_id = relateCompId;
          }
          if(ele_key == GENERAL_TYPES_MAP.area){
            //https://apib.hd.xxx.com/v1/feinit/data?site_id=&type=area
            this.initPost("/feinit/data", params)
          }else if(ele_key == GENERAL_TYPES_MAP.areaRank){
            //https://apib.hd.xxx.com/v1/feinit/number_info?site_id=1&type=arearank
            this.initPost("/feinit/number_info", params)
          }else if(ele_key == GENERAL_TYPES_MAP.lotteryForm){
            this.initPost("/feinit/Lottery_luckyform", params);
            params.isResultDisplay = true
          }else if(ele_key == GENERAL_TYPES_MAP.formrandlist) {
            delete params.ele_key
            //触发这个组件的组件id 提交按钮
            const relateCompId = getCompIdByParam(controlData.data.relateAttrCompId)
            if(relateCompId) {
              params.com_id = relateCompId
            }
            // https://apib.hd.xxx.com/v1/feinit/formrandlist?site_id=1580&com_id=0d5df569-1e8f-418c-86af-15bf02c7b4a6
            this.initPost("/feinit/formrandlist", params);
          }else {
            // http://apib.hd.xxx.com/v1/feinit/general?site_id=1229&com_id=&ele_key=puzzle
            // http://apib.hd.xxx.com/v1/feinit/general?site_id=1229&com_id=&ele_key=draw
            this.initPost("/feinit/general", params)
          }
        }else if(event.type == EVENT_HOVER_TYPES.user.type){
          if(event.isPost || !itemControls){
            return
          }
          let lists = itemControls[event.controlId].data.elements
          let customParams = itemControls[event.controlId].data.customParams;
          if(customParams && isJSON(customParams)){
            let customObj = JSON.parse(customParams);
            if(customObj.random){
              let newLists = _.shuffle(lists);
              lists = itemControls[event.controlId].data.elements = _.drop(newLists, newLists.length - customObj.length)
            }
          }
          let uids = []
          _.forEach(lists, (item) => {
            if(item.uid && item.uid.length > 0){
              uids.push(item.uid)
            }
          });
          let params = {event, uids: uids.join()}
          event.isPost = true
          this.initPost("/feinit/wb_head", params)
        }else if(event.type == EVENT_HOVER_TYPES.statisticData.type){
          let statisticDataType = event.comps[0].attrs.value;
          if(statisticDataType == STATISTIC_DATA_TYPES_MAP.aes){
            //加密条形码
            this.initPost("/feinit/Coupon", { event, isResultDisplay: true });
          }else if(statisticDataType == STATISTIC_DATA_TYPES_MAP.pk){
            //用户是否参数Pk
            this.initPost("/feinit/wb_pk", { event, isResultDisplay: true });
          }else if(statisticDataType == STATISTIC_DATA_TYPES_MAP.weibo2021vote){
            // 微博2021年抽奖
            this.initPost("/feinit/coupondraw", { event, isResultDisplay: true  })
          } else{
            //获取数据
            this.initPost("/feinit/wb_data", { event, type: statisticDataType })
          }
          event.isPost = true
        }else if(event.type == EVENT_HOVER_TYPES.timer.type){
          let params = {
            ele_key: 'activity',
          }
          this.initPost("/feinit/controls", params)
        }
      })
      if(this.item && this.item.cid == COMPONENT_TYPES.wb_input && (this.commonAttr.isAuto || this.commonAttr.userAttr) && !this.userInfo.isWbUserData){
        if(this.item.isPost){
          return
        }
        let params = {uid: ''}
        this.item.isPost = true
        this.initPost("/feinit/wb_head", params)
      }
    },
    onEventLink(event){
      let jumpUrl = event.comps[0].attrs.value
      let schema = event.comps[1].attrs.value
      let jumpKey = event.comps[2].attrs.value
      if (schema && isWeibo()) {
        jumpUrl = schema
      } else if (jumpKey) {
        jumpUrl = this.shareData[jumpKey]
        let relateCompId = getCompIdByParam(this.item.commonAttr.relateAttrCompId);
        if(!jumpUrl && relateCompId) {
          let relateCompData = this.componentMap[relateCompId];
          let relateItemData = this.getItemDataByCompData(relateCompId, relateCompData, this.commonAttr);
          jumpUrl = relateItemData[jumpKey]
          if(isWeibo() && jumpKey == "mid") {
            jumpUrl = "sinaweibo://detail/?mblogid=" + jumpUrl
          }
        }
      }
      if (jumpUrl && jumpUrl.length > 0) {
        if (top.location != self.location) {
          top.location.href = jumpUrl
        } else {
          this.openLinkBySelfUrl(jumpUrl);
        }
      }
    },
    openLinkBySelfUrl(jumpUrl) {
      let blocked = false;
      try {
        let worxWin = window.open(jumpUrl);
        if (worxWin == null) {
          blocked = true;
        }
      } catch (ex) {
        blocked = true;
      }
      if (blocked) {
        window.location.href = jumpUrl
      }
    },
  },
  beforeUnmount(){
    if(!this.item && this.currentPage){
      if(_.size(this.loadEvents) > 0){
        EventBus.$off("reloadLoad", this.onReloadLoad)
      }
      EventBus.$off("reloadInit", this.onReloadInit)
    }
  }
}
